import {
  getBannerData,
  getHotRecommendData,
  getNewAlbumData,
  getRecommendTopListData,
  getSettleArtistData,
  getHotDjData
} from '@/services/recommend-api'

import * as actionTypes from './constants'
const changeBannersAction = res => ({
  type: actionTypes.CHANGE_BANNERS_ACTION,
  banners:res
})
const changeHotRecommendDataAction = res => ({
  type: actionTypes.CAHNGE_HOT_RECOMMEND_DATA,
  hotRecommendList:res
})
const changeNewAlbumDataAction = res => ({
  type: actionTypes.CHANGE_NEW_ALBUM_DATA,
  newAlbumList:res
})
const changeFastTopListDataAction = res => ({
  type: actionTypes.CAHNGE_FAST_TOP_LIST_DATA,
  fastTopList:res
})
const changeNewTopListDataAction = res => ({
  type: actionTypes.CAHNGE_NEW_TOP_LIST_DATA,
  newTopList:res
})
const changeOrginTopListDataAction = res => ({
  type: actionTypes.CAHNGE_ORGIN_TOP_LIST_DATA,
  orginTopList:res
})
const changeSettleArtistDataAction = artistList => ({
  type: actionTypes.CHANGE_SETTLE_ARTIST_DATA,
  artistList
})
const changeHotDjDataAction = hotDjList => ({
  type: actionTypes.CHANGE_HOT_DJ_DATA,
  hotDjList
})
export const getBannersAction = () => {
  return async dispatch => {
    const res = await getBannerData()
    dispatch(changeBannersAction(res.banners))
  }
}
export const getHotRecommendDataAction = () => {
  return async dispatch => {
    const res = await getHotRecommendData()
    dispatch(changeHotRecommendDataAction(res.result))
  }
}
export const getNewAlbumDataAction = () => {
  return async dispatch => {
    const res = await getNewAlbumData(10)
    dispatch(changeNewAlbumDataAction(res.albums))
  }
}
export const getFastTopListDataAction = () => {
  return async dispatch => {
    const res = await getRecommendTopListData(3)
    dispatch(changeFastTopListDataAction(res.playlist))
  }
}
export const getNewTopListDataAction = () => {
  return async dispatch => {
    const res = await getRecommendTopListData(0)
    dispatch(changeNewTopListDataAction(res.playlist))
  }
}
export const getOrginTopListDataAction = () => {
  return async dispatch => {
    const res = await getRecommendTopListData(2)
    dispatch(changeOrginTopListDataAction(res.playlist))
  }
}
export const getSettleArtistDataAction = (cat,limit) => {
  return async dispatch => {
    const res = await getSettleArtistData(5001, 5)
    dispatch(changeSettleArtistDataAction(res.artists))
  }
}
export const getHotDjDataAction = limit => {
  return async dispatch => {
    const res = await getHotDjData(limit)
    dispatch(changeHotDjDataAction(res.djRadios))
  }
}